OPC Studio User's Guide and Reference
Installed Examples - Client Windows Forms - WindowsFormsApplication1

The simplest Windows Forms application. Reads and displays an OPC "Classic" (OPC-DA) item value on a form. This is what you get if you follow the steps described in Quick Start for QuickOPC.NET.

The form:

// $Header: $
// Copyright (c) CODE Consulting and Development, s.r.o., Plzen. All rights reserved.

// ReSharper disable NotNullMemberIsNotInitialized

//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

using System;
using System.Windows.Forms;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.OperationModel;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                object value = easyDAClient1.ReadItemValue("", "OPCLabs.KitServer.2", "Demo.Single");
                textBox1.Text = value?.ToString() ?? "";
            }
            catch (OpcException opcException)
            {
                textBox1.Text = $"*** {opcException.Message}";
            }
        }
    }
}
' $Header: $
' Copyright (c) CODE Consulting and Development, s.r.o., Plzen. All rights reserved.

'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET .
' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
' a commercial license in order to use Online Forums, and we reply to every post.

Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.OperationModel

Public Class Form1

    ' ReSharper disable InconsistentNaming
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As EventArgs) Handles MyBase.Load
        ' ReSharper restore InconsistentNaming

        Try
            TextBox1.Text = EasyDAClient1.ReadItemValue("", "OPCLabs.KitServer.2", "Demo.Single")
        Catch opcException As OpcException
            TextBox1.Text = $"*** {opcException.Message}"
        End Try
    End Sub
End Class

 

See Also

Examples

Concepts

Getting Started

Installed Examples - Client WPF

Installed Examples - Client Console